




/*
*************************************************************************
*西瑞克斯研发管理系统
*版 本: 1.0   
*日 期：03/02/2012    
*作 者： 王浩 QQ：873987060   
*************************************************************************   
*/ 
package com.application.transitiondownlog.struts.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.manager.commons.config.ConfigFactory;
import com.manager.commons.page.PageBean;
import com.manager.commons.RandomKey;
import com.manager.commons.CommonUtil;
import com.application.transitiondownlog.entity.Transitiondownlog;
import com.application.transitiondownlog.struts.form.TransitiondownlogForm;
import com.application.transitiondownlog.service.TransitiondownlogService;
import com.application.transitiondownlog.commons.Constants;
 /**
 * 
 * Description:TransitiondownlogAction<br />
 * 
 * Version:V0.1<br />
 * 
 * Author: 王浩 QQ：873987060    <br />
 * 
 * History: <br />
 * 
 * 03/02/2012 
 * 
 */
public class TransitiondownlogAction extends DispatchAction
{
       
       /**
	 * Service层实例
	 */
	private TransitiondownlogService transitiondownlogService;

	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * 实体对象
	 */
        private Transitiondownlog transitiondownlog;


        /**
	 * 采用partialList方式分页程序
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public ActionForward getTransitiondownlogPartialList(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("searchTransitiondownlog" + "开始");
		TransitiondownlogForm transitiondownlog = (TransitiondownlogForm)form;
		// 统计总记录数的sql语句
		int resultSize = 0;
		// 初始化pageBean供分页所用
		PageBean pageBean = null;
		// 取得当前页list数据
		List transitiondownlogList = null;
//		resultSize = transitiondownlogService.getAllCountTransitiondownlog(transitiondownlog);
//		pageBean = PageBean.getPageBean("transitiondownlogTab", resultSize,request);
		transitiondownlogList = transitiondownlogService.searchTransitiondownlog(transitiondownlog,pageBean);
		request.setAttribute("transitiondownlogList", transitiondownlogList);

		log.debug("searchTransitiondownlog" + "结束");

		return mapping.findForward(Constants.SUCCESS);
	}

        /**
	 * 到达新增页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toAddTransitiondownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toAddTransitiondownlogs");
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 增加
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward addTransitiondownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("addTransitiondownlogs");
		Transitiondownlog transitiondownlog = this.getTransitiondownlog(form);
                transitiondownlog.setId(RandomKey.generateID_Long_19());
		 transitiondownlog.setOperateid(CommonUtil.getCurrentUser(request).getId());
		 transitiondownlog.setCreateDate(new Date());

		this.transitiondownlogService.insertObject(transitiondownlog);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 删除
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward deleteTransitiondownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("deleteTransitiondownlogs");
		TransitiondownlogForm transitiondownlogForm = (TransitiondownlogForm) form;
		this.transitiondownlogService.deleteTransitiondownlogs(transitiondownlogForm);
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 到达更新页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toUpdateTransitiondownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toUpdateTransitiondownlogs");

		Transitiondownlog transitiondownlog = this.getTransitiondownlog(form);
		transitiondownlog = this.transitiondownlogService.getTransitiondownlog(transitiondownlog);
		request.setAttribute(Constants.YFPLACEFILEDOWNLOG, transitiondownlog);
		return mapping.findForward(Constants.SUCCESS);
	}

        
	/**
	 * 更新
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward updateTransitiondownlog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("updateTransitiondownlogs");
		Transitiondownlog transitiondownlog = this.getTransitiondownlog(form);
	        transitiondownlog.setOperateid(CommonUtil.getCurrentUser(request).getId());
		 transitiondownlog.setCreateDate(new Date());
		this.transitiondownlogService.updateObject(transitiondownlog);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 查看页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward viewTransitiondownlog(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		log.debug("viewTransitiondownlog");

		Transitiondownlog transitiondownlog = this.getTransitiondownlog(form);
		transitiondownlog = this.transitiondownlogService.getTransitiondownlog(transitiondownlog);
		request.setAttribute(Constants.YFPLACEFILEDOWNLOG, transitiondownlog);
		return mapping.findForward(Constants.SUCCESS);
	}

	// get--set
	/**
	 * @return the TransitiondownlogService
	 */
	public TransitiondownlogService getTransitiondownlogService() {
		return this.transitiondownlogService;
	}

	/**
	 * @param TransitiondownlogService
	 *  the TransitiondownlogService to set
	 */
	public void setTransitiondownlogService(TransitiondownlogService transitiondownlogService) {
		this.transitiondownlogService = transitiondownlogService;
	}

	/**
	 * 获取Transitiondownlog实体
	 * @param ActionForm
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 * @return the Transitiondownlog
	 */
	public Transitiondownlog getTransitiondownlog(ActionForm form) throws IllegalAccessException, InvocationTargetException {
		TransitiondownlogForm transitiondownlogForm = (TransitiondownlogForm) form;
		transitiondownlog = new Transitiondownlog();
		BeanUtils.copyProperties(transitiondownlog, transitiondownlogForm);
		return transitiondownlog;
	}
    
        public void setTransitiondownlog(Transitiondownlog transitiondownlog) {
		this.transitiondownlog = transitiondownlog;
	}

}
